Skip to content

Path traversal protection in unzip to temp file#45691

Open
ayushhgarg-work wants to merge 9 commits intoAzure:mainfrom
ayushhgarg-work:ayushhgarg/jobinvoker
Open

Path traversal protection in unzip to temp file#45691
ayushhgarg-work wants to merge 9 commits intoAzure:mainfrom
ayushhgarg-work:ayushhgarg/jobinvoker

Conversation

@ayushhgarg-work
Copy link
Member

@ayushhgarg-work ayushhgarg-work commented Mar 13, 2026

Fixes MSRC [110063] — two path traversal vulnerabilities in _local_job_invoker.py.

Fix 1: unzip_to_temporary_file now validates all ZIP member paths resolve within the target directory before extraction.

Fix 2: New _safe_tar_extractall helper replaces raw tarfile.extract() in copy_bootstrapper_from_container. Uses filter='data' on Python 3.12+; on older versions, manually blocks path traversal, symlinks, and hard links.

7 security regression tests added. All 10 tests passing, 0 regressions.

image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens azure-ai-ml local job execution utilities against archive extraction vulnerabilities (ZipSlip/TarSlip) by validating ZIP members before extraction and adding a safer TAR extraction helper, along with new unit tests for the security behavior.

Changes:

  • Add ZIP member validation to block path traversal before extractall() in unzip_to_temporary_file.
  • Introduce _safe_tar_extractall and use it when extracting the bootstrapper archive from a Docker container.
  • Add unit tests covering ZIP/TAR path traversal and link-handling scenarios.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 7 comments.

File Description
sdk/ml/azure-ai-ml/azure/ai/ml/operations/_local_job_invoker.py Adds ZIP path validation and a safe TAR extraction helper; switches bootstrapper extraction to use the safer path.
sdk/ml/azure-ai-ml/tests/job_common/unittests/test_local_job_invoker.py Adds unit tests for ZIP/TAR extraction safety and related rejection cases.

You can also share your feedback on Copilot code review. Take the survey.

@ayushhgarg-work
Copy link
Member Author

@microsoft-github-policy-service rerun

@ayushhgarg-work ayushhgarg-work enabled auto-merge (squash) March 18, 2026 11:26
@ayushhgarg-work
Copy link
Member Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants